<?
define('BASEPATH', true);
include('../inc/config.php');
if($is_online){
	if(isset($_GET['data'])){
		$sid = $db->EscapeString($_GET['data']);
		$site = $db->FetchArray($db->Query("SELECT id,cpc FROM `surf` WHERE `id`='".$sid."'"));
		$check = $db->GetNumRows($db->Query("SELECT * FROM `surfed` WHERE `user`='".$data['id']."' AND `site`='".$sid."'"));
		if($site['id'] != "" && $check == 0){
			$db->Query("UPDATE `users` SET `coins`=`coins`+'".$site['cpc']."' WHERE `id`='".$data['id']."'");
			$db->Query("UPDATE `surf` SET `visits`=`visits`+'1', `points`=`points`-'".$site['cpc']."' WHERE `id`='".$site['id']."'");
			$db->Query("INSERT INTO `surfed` (user, site) VALUES('".$data['id']."', '".$site['id']."')");
		}
	}
}
?>